﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IntelligentDecisioning.SharePoint.BusinessEntities;
using IntelligentDecisioning.SharePoint.Shared;
using Microsoft.SharePoint;

namespace IntelligentDecisioning.SharePoint.repositories
{
    /// <summary>
    /// A CRUD interface for items stored in sharepoint list repositories. 
    /// This sigle interface is implemented for all repositories in the SharePointList class
    /// </summary>
    public interface IListItemRepository<T> where T : ListItemEntityBase, new()
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        T AddEntity(T entity);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        List<T> AddEntities(List<T> entities);

       /// <summary>
       /// 
       /// </summary>
       /// <returns></returns>
        List<T> GetEntities();


       /// <summary>
       /// 
       /// </summary>
       /// <param name="query"></param>
       /// <returns></returns>
        List<T> GetEntities(SPQuery query);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        List<T> GetEntities(SPView view);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        /// <param name="view"></param>
        /// <returns></returns>
        List<T> GetEntities(SPQuery query, SPView view);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        T GetEntity(SPQuery query);



        /// <summary>
        /// 
        /// </summary>
        void DeleteEntities();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        void DeleteEntity(T entity);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        List<T> UpdateEntities(List<ListItemEntityBase> entities);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        T UpdateEntity(T entity);

        /// <summary>
        /// Initialise the repository
        /// </summary>
        /// <param name="listName"></param>
        /// <param name="context"></param>
        void InitialiseRepository(string listName, IDSharePointContext context);
    }
}
